import React from "react";
import { Route, Redirect } from "react-router-dom";

const Auth = (props) => {
  return (
    <Route
      path={props.path}
      render={() => {
        if (localStorage.getItem("token")) {
          return props.children;
        } else {
          return <Redirect to="/login"></Redirect>;
        }
      }}
    ></Route>
  );
};

export default Auth;
